package exec;

import java.io.*;
import java.util.UUID;

public class FileEncrypt {

	public static void main(String[] args) throws IOException {
		File from = new File(
				"C:\\Users\\Administrator\\Desktop\\2017-11-13_140755.png");
		FileInputStream fis = new FileInputStream(from);// 源文件
		// File to = new File(UUID.randomUUID().toString());
		File to = new File(String.valueOf(Math.random())
				+ String.valueOf(Math.random()) + String.valueOf(Math.random()));
		FileOutputStream fos = new FileOutputStream(to);
		int temp;
		while ((temp = fis.read()) != -1) {
			temp = ~temp; // 加密过程

			fos.write(temp);

		}
		fis.getFD();

		fos.close();
		fis.close();
		from.delete();
		to.renameTo(from);

	}
}
